/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sharedObjects;

import java.awt.Point;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Niclas
 */


public class FieldStorage {
    public List<Field>fieldList = new ArrayList<Field>();
    
    public Field getFieldByCoordinates(Point p){
        
        for (int i = 0; i < fieldList.size();i++){
            Field f = fieldList.get(i);
            int ulx = f.getUpperLeftPixels().x;
            int lrx = f.getLowerRightPixels().x;
            int uly = f.getUpperLeftPixels().y;
            int lry = f.getLowerRightPixels().y;
            if(ulx < p.x &&
               lrx > p.x &&
               uly < p.y &&
               lry > p.y)
            {
                return fieldList.get(i);
            }
        }
        return null;
        }
    
}
